Skip to content

[SYCL][UR][L0 v2] import host ptr when SYCL_USM_HOSTPTR_IMPORT=1 and fix mapHostPtr #19297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: sycl
Choose a base branch
from

Conversation

igchor
Copy link
Member

@igchor igchor commented Jul 3, 2025

No description provided.

@igchor igchor requested a review from a team as a code owner July 3, 2025 17:37
@igchor igchor temporarily deployed to WindowsCILock July 3, 2025 17:37 — with GitHub Actions Inactive
@igchor igchor temporarily deployed to WindowsCILock July 3, 2025 17:59 — with GitHub Actions Inactive
@igchor igchor temporarily deployed to WindowsCILock July 3, 2025 17:59 — with GitHub Actions Inactive
igchor added 2 commits July 3, 2025 18:26
This matches v1 functionality and speeds up subsequent
buffer map/unmap operations by making memory copy faster.
The logic for freeing mappedPtr was incorrect. We should only free
the memory in unmapHostPtr if the pointer was allocated in mapHostPtr,
not the other way around.
Copy link
Contributor

@pbalcer pbalcer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but tests seem to be failing:

native_specialization_constant

ur_integrated_buffer_handle_t(ur_context_handle_t hContext, void *hostPtr,
size_t size, host_ptr_action_t useHostPtr,
device_access_mode_t accesMode);
size_t size, device_access_mode_t accesMode);

ur_integrated_buffer_handle_t(ur_context_handle_t hContext, void *hostPtr,
size_t size, device_access_mode_t accesMode,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
size_t size, device_access_mode_t accesMode,
size_t size, device_access_mode_t accessMode,

(I know, unrelated to this PR :P)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@igchor igchor temporarily deployed to WindowsCILock July 7, 2025 16:00 — with GitHub Actions Inactive
@igchor
Copy link
Member Author

igchor commented Jul 7, 2025

lgtm, but tests seem to be failing:

native_specialization_constant

Fixed. It seems that UR_MEM_FLAG_USE_HOST_POINTER does not have to be set when hostPtr is not null. In the legacy adapter this flag controlled whether to import the memory to USM or not but I don't see a reason not to do it in all cases. It seems that SYCL almost always sets UR_MEM_FLAG_USE_HOST_POINTER anyway (except in that one test)

@igchor igchor temporarily deployed to WindowsCILock July 7, 2025 16:36 — with GitHub Actions Inactive
@igchor igchor temporarily deployed to WindowsCILock July 7, 2025 16:36 — with GitHub Actions Inactive
@igchor
Copy link
Member Author

igchor commented Jul 7, 2025

Actually, I wonder why do we event support that combination (non-null hostPtr and no USE_HOST_PTR flag). OpenCL doesn't seem to allow this: https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clCreateBuffer.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants